var express = require('express');
var router = express.Router();
var rssReader = require(_ROOT + '/app/data/rssReader');

// TODO Change url (rssToJson)
router.get('/xmlToJson/:url', function(req, res) {
  // rssReader.read() returns array of JSON objects.
  rssReader.read(req.params.url).then(function(data){
    res.json(data);
    res.end();
  }, function(err) {
    res.end(err);
  });
});

module.exports = router;